<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace core\utils;

class TimeGen
{
    public static function gen24Hour(): array
    {
        $x = [];
        for ($i = 0; $i < 24; ++$i) {
            $x[] = $i;
        }
        return $x;
    }

    public static function genDateFromRange($start, $end): array
    {
        $end = date('Y-m-d', strtotime($end)); // 转换为月
        $range = [];
        $i = 0;
        do {
            $month = date('Y-m-d', strtotime($start . ' + ' . $i . ' day'));
            $range[] = $month;
            ++$i;
        } while ($month < $end);
        return $range;
    }
}
